<div id="backPageMenu">
   <a href="/about-us/">&Uuml;ber Uns</a>
   <a href="/online-help/">Online Hilfe</a>
   <a href="/privacy-policy/">Datenschutzrichtlinie</a>
   <a href="/terms-and-conditions/">Allgemeine Bedingungen</a>
</div>

<div id="aboutus">

<?php
	// Get email address
	$email = $_POST['email_address'];
	$date = date("F j, Y, g:i a");

	function check_email_address($email) {
	  // First, we check that there's one @ symbol, and that the lengths are right
	  if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
		// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
		return false;
	  }
	  // Split it into sections to make life easier
	  $email_array = explode("@", $email);
	  $local_array = explode(".", $email_array[0]);
	  for ($i = 0; $i < sizeof($local_array); $i++) {
		if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
		  return false;
		}
	  }
	  if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
		$domain_array = explode(".", $email_array[1]);
		if (sizeof($domain_array) < 2) {
		  return false; // Not enough parts to domain
		}
		for ($i = 0; $i < sizeof($domain_array); $i++) {
		  if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
			return false;
		  }
		}
	  }
	  return true;
	}
	
	$email_result = check_email_address($email);
	
	if($email_result){
		$message = "<p>Danke! Ihre E-Mail Adresse wurde erfolgreich an allesfuerhandys weitergeleitet.</p>";
		$sql	 = "INSERT INTO Newsletters(Site, EmailAddress, Competition, TimeStamp) VALUES('COS', '".$email."', 'Natural Traffic', '".$date."')";
		$query	 = mysql_query($sql) or die(mysql_error());
	}else{
		$message  = "<p>Es gab ein Problem Ihre E-Mail Adresse zu verarbeiten. Bitte geben Sie sie unterhalb noch einmal ein.</p>";
		$message .= "<form action=\"/submit-email/\" method=\"post\">";
		$message .= "	<input type=\"text\" name=\"email_address\">";
		$message .= "	<input type=\"submit\" value=\"Submit\">";
		$message .= "</form>";
	}
?>

    <div class="heading">
    	<div class="headingTitleLeft"></div>
    	<div class="headingTitle"><h3>allesfuerhandys Email Eingabe</h3></div>
    	<div class="headingTitleRight"></div>
    </div>
    <div class="textBox">
    	<div class="text">
        	<img src="/images/aboutus/icon_01.png" width="143" height="135" alt="" style="float:right; margin:-55px -20px 0px 10px; position:relative;" />
    		<!--<p>Thank you for submitting your email address to Costbiter.</p>-->
			<?php echo $message; ?>			
    	</div>
    </div>
</div>